package org.rsbot.util;

import java.awt.Container;
import java.awt.Toolkit;
import java.io.File;

import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.JWindow;


/* @auther Sorcermus
 * April 21, 2010 runedev
 */
public class SplashScreen extends JWindow {

    private static final long serialVersionUID = 7872136286561774212L;
    private JLabel name = new JLabel();
    public JProgressBar progress = new JProgressBar();
    private ImageIcon icon = new ImageIcon();

    public SplashScreen() {
        splash();

    }

    private void splash() {
        Container contentPane = getContentPane();
        try {
            this.icon.setImage(Toolkit.getDefaultToolkit().getImage(GlobalConfiguration.RUNNING_FROM_JAR ? getClass().getResource(GlobalConfiguration.Paths.Resources.SPLASH) : new File(GlobalConfiguration.Paths.SPLASH).toURI().toURL()));
        } catch (final Exception e) {
        }
        progress.setIndeterminate(true);
        progress.setLocation(190, 130);
        progress.setSize(250, 14);
        progress.setOpaque(true);
        this.name.setSize(450, 150);
        this.name.setLocation(0, 0);
        this.name.setIcon(icon);
        this.name.add(progress);
        this.add(name);

        GroupLayout contentPaneLayout = new GroupLayout(contentPane);
        contentPane.setLayout(contentPaneLayout);
        contentPaneLayout.setHorizontalGroup(contentPaneLayout.createParallelGroup().addGroup(
                contentPaneLayout.createSequentialGroup().addContainerGap().addGroup(
                contentPaneLayout.createParallelGroup().addGroup(
                contentPaneLayout.createSequentialGroup().addContainerGap(
                699,
                32767)))));

        contentPaneLayout.setVerticalGroup(contentPaneLayout.createParallelGroup().addGroup(
                contentPaneLayout.createSequentialGroup().addContainerGap().addContainerGap(16, 32767)));

        pack();
        this.setSize(450, 150);

    }

    public void SplashMain() {
        this.setVisible(true);

    }
}
